package com.guangzhi.weijianzhi.http;

import com.guangzhi.weijianzhi.context.WeiJianZhiEntity;
import com.guangzhi.weijianzhi.entity.PublishPositionEntity;
import com.loopj.android.http.AsyncHttpClient;
import com.loopj.android.http.AsyncHttpResponseHandler;
import com.loopj.android.http.RequestParams;
/**
 * 所有的请求接口类
 * @author Administrator
 *
 */
public class HttpRequestUtils {
	public static AsyncHttpClient mAsyncHttpClient = new AsyncHttpClient();
	
	/**
	 * 这是一个例子
	 * @param name
	 * @param pas
	 * @param asyncHttpResponseHandler
	 */
	public static void requestHttpLogin(String name,String pas,AsyncHttpResponseHandler Handler){
		RequestParams requestParams = new RequestParams();
		requestParams.put("", name);
		requestParams.put("", pas);
	//	mAsyncHttpClient.get(HttpUrls.isLogin,requestParams,Handler);
	}
	/**
	 * 首页获取专区列表
	 * @param access_token
	 * @param Handler
	 */
	public static void doHttpDateList(AsyncHttpResponseHandler Handler){
		RequestParams requestParams = new RequestParams();
		requestParams.put("client_id", "android");
		requestParams.put("client_secret", "61bcd762eaa9f3b2a891f33661ddaf42");
		mAsyncHttpClient.post(HttpUrls.AREADATALIST,requestParams,Handler);
	}
	
	/**
	 * 获取banner
	 * @param name
	 * @param pas
	 * @param Handler
	 */
	public static void doHttpBanner(AsyncHttpResponseHandler Handler){
		RequestParams requestParams = new RequestParams();
		requestParams.put("client_id", "android");
		requestParams.put("position", "index");
		requestParams.put("client_secret", "61bcd762eaa9f3b2a891f33661ddaf42");
		mAsyncHttpClient.get(HttpUrls.BANNERDATALIST,requestParams,Handler);
	}
	
	/**
	 * 登录返回code
	 * @param username
	 * @param password
	 * @param Handler
	 */
	public static void doHttpLogin(String username,String password,AsyncHttpResponseHandler Handler){
		RequestParams params = new RequestParams();
		params.put("grant_type", "client_credentials");
        params.put("client_id", "android");
        params.put("client_secret", "61bcd762eaa9f3b2a891f33661ddaf42");
        params.put("response_type", "code");
        params.put("state", "xyz");
        params.put("authorized", "yes");
        params.put("username", username);
        params.put("password", password);
		mAsyncHttpClient.post(HttpUrls.DOLOGIN,params,Handler);
	}
	/**
	 * 根据code获取数据
	 * @param username
	 * @param password
	 * @param Handler
	 */
	public static void doHttpLoginData(String code,AsyncHttpResponseHandler Handler){
		RequestParams params = new RequestParams();
		params.put("grant_type", "authorization_code");
        params.put("client_id", "android");
        params.put("client_secret", "61bcd762eaa9f3b2a891f33661ddaf42");
        params.put("code", code);
		mAsyncHttpClient.post(HttpUrls.DOLOGINDATA,params,Handler);
	}
	
	
	public static void doHttpRegisterCode(String tel,AsyncHttpResponseHandler Handler){
		RequestParams params = new RequestParams();
		params.put("client_id", "android");
		params.put("client_secret", "61bcd762eaa9f3b2a891f33661ddaf42");
		params.put("tel", tel);
		mAsyncHttpClient.post(HttpUrls.DOREGISTERCODE,params,Handler);
	}
	/**
	 * 注册
	 * @param tel
	 * @param password
	 * @param messageCode
	 * @param Handler
	 */
	
	public static void doHttpRegister(String tel,String password,String messageCode,AsyncHttpResponseHandler Handler){
		RequestParams params = new RequestParams();
		params.put("client_id", "android");
		params.put("client_secret", "61bcd762eaa9f3b2a891f33661ddaf42");
		params.put("tel", tel);
		params.put("password", password);
		params.put("pincode", password);
		params.put("messageCode", messageCode);
		mAsyncHttpClient.post(HttpUrls.DOREGISTER,params,Handler);
	}
	/**
	 * 用户选择通道
	 * @param access_token
	 * @param userType
	 * @param Handler
	 */
	
	public static void doHttpRegisterSelect(String access_token,String userType,AsyncHttpResponseHandler Handler){
		RequestParams params = new RequestParams();
		params.put("access_token", access_token);
		params.put("userType", userType);
		mAsyncHttpClient.post(HttpUrls.RESETUSERTYPE,params,Handler);
	}
	
	/**
	 * 提交公司注册数据
	 * @param access_token
	 * @param company_name
	 * @param type
	 * @param vocation
	 * @param scale
	 * @param contacts_name
	 * @param contacts_tel
	 * @param area
	 * @param full_address
	 * @param intro
	 * @param picurl
	 * @param Handler
	 */
	public static void doHttpSubComData(String access_token,String company_name,String type,String vocation,
			String scale,String contacts_name,String contacts_tel,String area,String full_address,String intro,String picurl,
			AsyncHttpResponseHandler Handler){
		RequestParams params = new RequestParams();
		params.put("access_token", access_token);
		params.put("company_name", company_name);
		params.put("type", type);
		params.put("vocation", vocation);
		params.put("scale", scale);
		params.put("contacts_name", contacts_name);
		params.put("contacts_tel", contacts_tel);
		params.put("area", area);
		params.put("full_address", full_address);
		params.put("intro", intro);
		params.put("picurl", picurl);
		mAsyncHttpClient.post(HttpUrls.ADDCOMPANY,params,Handler);
	}
	
	/**
	 * 初始化公司信息
	 * @param access_token
	 * @param Handler
	 */
	public static void doHttpSubComData(String access_token,
			AsyncHttpResponseHandler Handler){
		RequestParams params = new RequestParams();
		params.put("access_token", access_token);
		mAsyncHttpClient.post(HttpUrls.ADDCOMPANY,params,Handler);
	}
	
	/**
	 * 获取最热职位
	 * @param access_token
	 * @param area
	 * @param page
	 * @param Handler
	 */
	public static void doHttpHotText(String area,int page,
			AsyncHttpResponseHandler Handler){
		RequestParams params = new RequestParams();
		params.put("client_id", "android");
		params.put("client_secret", "61bcd762eaa9f3b2a891f33661ddaf42");
		params.put("select ","index");
	//	params.put("area",area);
		params.put("page ",page);
		mAsyncHttpClient.get(HttpUrls.GETJOBLISTBYOPTION,params,Handler);
	}
	
	/**
	 * 获取最热职位详情
	 * @param area
	 * @param page
	 * @param Handler
	 */
	public static void doHttpHotTextDetails(String jobId,
			AsyncHttpResponseHandler Handler){
		RequestParams params = new RequestParams();
		params.put("client_id", "android");
		params.put("client_secret", "61bcd762eaa9f3b2a891f33661ddaf42");
		params.put("jobId",jobId);
		mAsyncHttpClient.get(HttpUrls.GETJOBDETAIL,params,Handler);
	}
	
	/**
	 * 报名
	 * @param jobId
	 * @param access_token
	 * @param Handler
	 */
	public static void doHttpHotTextapply(String jobId,String access_token,
			AsyncHttpResponseHandler Handler){
		RequestParams params = new RequestParams();
		params.put("jobId",jobId);
		params.put("access_token", access_token);
		mAsyncHttpClient.get(HttpUrls.GETJOBDETAIL,params,Handler);
	}
	/**
	 * 投诉建议
	 * @param jobId
	 * @param access_token
	 * @param Handler
	 */
	public static void doHttpSettingOpinion(String access_token,String content,
			AsyncHttpResponseHandler Handler){
		RequestParams params = new RequestParams();
		params.put("access_token", access_token);
		params.put("PhoneModel", android.os.Build.MODEL);
		params.put("content",content);
		mAsyncHttpClient.post(HttpUrls.FEEDBACK,params,Handler);
	}
	
	
	/**
	 * 获取设置数据
	 * @param access_token
	 * @param Handler
	 */
	public static void doHttpSettingItem(
			AsyncHttpResponseHandler Handler){
		RequestParams params = new RequestParams();
		params.put("client_id", "android");
		params.put("client_secret", "61bcd762eaa9f3b2a891f33661ddaf42");
		mAsyncHttpClient.get(HttpUrls.GETWEIJOBINFO,params,Handler);
	}
	
	/**
	 * 从职位信息里面获取公司详情
	 * @param Handler
	 */
	public static void doHttpMianComInfo(String comapnyId,
			AsyncHttpResponseHandler Handler){
		RequestParams params = new RequestParams();
		params.put("client_id", "android");
		params.put("client_secret", "61bcd762eaa9f3b2a891f33661ddaf42");
		params.put("comapnyId", comapnyId);
		mAsyncHttpClient.post(HttpUrls.COMPANYDETAIL,params,Handler);
	}
	/**
	 * 修改登录密码验证码
	 * @param Handler
	 */
	public static void doHttpAlterLoginPassword(
			AsyncHttpResponseHandler Handler){
		RequestParams params = new RequestParams();
		params.put("access_token", WeiJianZhiEntity.access_token);
		mAsyncHttpClient.post(HttpUrls.RESETPASSWORD,params,Handler);
	}
	/**
	 * 提交修改密码
	 * @param oldPassword
	 * @param newPassword
	 * @param messageContent
	 * @param Handler
	 */
	public static void doHttpAlterLoginPasswordCommit(String oldPassword,String newPassword,String messageContent,
			AsyncHttpResponseHandler Handler){
		RequestParams params = new RequestParams();
		params.put("access_token", WeiJianZhiEntity.access_token);
		params.put("oldPassword", oldPassword);
		params.put("newPassword", newPassword );
		params.put("messageContent",messageContent);
		mAsyncHttpClient.post(HttpUrls.RESETPASSWORDCOMMIT,params,Handler);
	}
	
	/**
	 * 发布职位
	 * @param depict
	 * @param contacts_name
	 * @param contacts_tel
	 * @param addServerDay
	 * @param add_service
	 * @param Handler
	 */
	public static void doHttpPublishPosition(String depict,String contacts_name,String contacts_tel,String addServerDay, String add_service,
			AsyncHttpResponseHandler Handler){
		RequestParams params = new RequestParams();
		params.put("access_token", WeiJianZhiEntity.access_token);
		params.put("title",PublishPositionEntity.posiName);
		params.put("position",PublishPositionEntity.posiType);
		params.put("employ_num",PublishPositionEntity.posiNumber);
		params.put("bonus", PublishPositionEntity.posiPay );
		params.put("bonus_type",PublishPositionEntity.bouns_type);
		params.put("job_date",PublishPositionEntity.posiData);
		params.put("job_time",PublishPositionEntity.positime);
		params.put("area",PublishPositionEntity.posiArea);
		params.put("full_address",PublishPositionEntity.posiAddress);
		params.put("depict",depict);
		params.put("contacts_name",contacts_name );
		params.put("contacts_tel",contacts_tel  );
		if(!"0".equals(add_service)){
			params.put("addServerDay",addServerDay  );
			params.put("add_service",add_service   );
		}
		
		mAsyncHttpClient.post(HttpUrls.PUBLISHJOB,params,Handler);
	}
/**
 * 设置支付密码
 * @param PayPassword
 * @param rePayPassword
 * @param Handler
 */
	public static void doHttpSetPassword(String PayPassword,String rePayPassword,
			AsyncHttpResponseHandler Handler){
		RequestParams params = new RequestParams();
		params.put("access_token", WeiJianZhiEntity.access_token);
		params.put("PayPassword", PayPassword);
		params.put("rePayPassword", rePayPassword );
		mAsyncHttpClient.post(HttpUrls.SETPAYPASSWORD,params,Handler);
	}
	
	/**
	 * 设置头像
	 * @param avatar
	 * @param Handler
	 */
	public static void doHttpUserPic(String avatar,
			AsyncHttpResponseHandler Handler){
		RequestParams params = new RequestParams();
		params.put("access_token", WeiJianZhiEntity.access_token);
		params.put("avatar", avatar);
		mAsyncHttpClient.post(HttpUrls.EDITUSERINFO,params,Handler);
	}
	public static void doHttpPayJob(String jobId,String bonus,String paypassword ,String bos ,
			AsyncHttpResponseHandler Handler){
		RequestParams params = new RequestParams();
		params.put("access_token", WeiJianZhiEntity.access_token);
		params.put("jobId", jobId);
		params.put("payWay", bonus);
		if(!"".equals(paypassword)){
			params.put("paypassword", paypassword );
		}
		
		params.put("bonus", bos );
		mAsyncHttpClient.post(HttpUrls.PAYJOB,params,Handler);
	}
}
